<template>
	<view class="headerTop" :style="{height:searchBarHeight+'px',marginTop:searchBarTop+'px'}">
		<!-- 头部 -->
		<uni-icons type="back" size="30" @click="back" class="iconClass" color="#fff"></uni-icons>
		<view class="title">
			<slot name="title"></slot>
		</view>
	</view>
</template>
<script>
	export default ({
		data() {
			return {
				searchBarTop: 0, //margin高度，单位px
				searchBarHeight: 0, //导航栏高度，单位px
			}
		},
		methods: {
			// 返回上一页
			back() {
				if (uni.getStorageSync('tempState') == 'yes') {
					uni.setStorageSync('tempState', 'no')
				}
				uni.navigateBack();
			},
		},
		mounted() {
			let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
			this.searchBarTop = menuButtonInfo.top;
			this.searchBarHeight = menuButtonInfo.height;
		}
	})
</script>
<style lang="scss" scoped>
	.headerTop {
		width: 100%;
		// height: 88rpx;
		display: flex;
		align-items: center;
		// margin-top: 58rpx;
		position: relative;

		.iconClass {
			margin-left: 34rpx;
		}

		.title {
			position: absolute;
			top: 50%;
			left: 50%;
			font-size: 40rpx;
			transform: translate(-50%, -50%);
			font-family: PingFang SC-Bold, PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
		}
	}
</style>